﻿using BCData.Sim.Admin.AdminSpecificPermission;
using BCDto.Sim.Admin.AdminSpecificPermission;
using BCService.Utils;
using System.Collections.Generic;

namespace BCService.Sim.Admin.AdminSpecificPermissionService
{
    public class AdminSpecificPermissionService: IAdminSpecificPermissionService
    {
        private readonly IAdminSpecificPermissionData adminSpecificPermissionData;

        public AdminSpecificPermissionService(IAdminSpecificPermissionData adminSpecificPermissionData)
        {
            this.adminSpecificPermissionData = adminSpecificPermissionData;
        }

        public AdminSpecificPermissionDto Get(int adminSpecificPermissionId)
        {
            return this.adminSpecificPermissionData.Get(adminSpecificPermissionId).GetAwaiter().GetResult().As<AdminSpecificPermissionDto>();
        }

        public AdminSpecificPermissionDto Get(string extensionPermissionKey)
        {
            return this.adminSpecificPermissionData.Get(extensionPermissionKey).GetAwaiter().GetResult().As<AdminSpecificPermissionDto>();
        }

        public IEnumerable<AdminSpecificPermissionDto> List()
        {
            return this.adminSpecificPermissionData.Query().GetAwaiter().GetResult().As<IEnumerable<AdminSpecificPermissionDto>>();
        }
    }
}
